Created
July 25, 2013 14:04
-
-
Save 7shi/6079981 to your computer and use it in GitHub Desktop.
PDP-11 to 8086 translation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main(argc, argv) int argc; char *argv[]; { | |
int i; | |
for (i = 0; i < argc; i++) { | |
printf("%d: %s\n", i, argv[i]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.globl _main | |
.text | |
_main: | |
~~main: | |
~argc=4 | |
~argv=6 | |
~i=177770 | |
jsr r5,csv | |
tst -(sp) | |
clr -10(r5) | |
L2:cmp 4(r5),-10(r5) | |
jle L3 | |
mov -10(r5),r0 | |
asl r0 | |
add 6(r5),r0 | |
mov (r0),(sp) | |
mov -10(r5),-(sp) | |
mov $L5,-(sp) | |
jsr pc,*$_printf | |
cmp (sp)+,(sp)+ | |
L4:inc -10(r5) | |
jbr L2 | |
L3:L1:jmp cret | |
.globl | |
.data | |
L5:.byte 45,144,72,40,45,163,12,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.extern _main | |
.sect .text | |
_main: | |
! ~~main: | |
! ~argc=4 | |
! ~argv=6 | |
! ~i=177770 | |
call csv | |
sub sp, #2 | |
mov -8(bp), #0 | |
L2:mov bx, 4(bp); cmp bx, -8(bp) | |
jle L3 | |
mov ax, -8(bp) | |
sal ax, #1 | |
add ax, 6(bp) | |
add sp, #2; mov bx, ax; mov bx, (bx); push bx | |
mov bx, -8(bp); push bx | |
mov bx, #L5; push bx | |
call _printf | |
add sp, #4 | |
L4:inc -8(bp) | |
jmp L2 | |
L3:L1:jmp cret | |
! .globl | |
.sect .data | |
L5:.data1 0x25, 0x64, 0x3a, 0x20, 0x25, 0x73, 0x0a, 0x00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment