Data update

This commit is contained in:
Ingy dot Net 2024-04-19 16:56:29 -07:00
parent 0df55f9f24
commit aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions

View file

@ -0,0 +1,25 @@
$constant CODESIZE = 4 rem - size of our ml routine
$constant ML_LOC = 011AH rem - beginning of common data area
dim common byte ml_code(CODESIZE)
var hl, de, bc, a_psw = integer
comment
The 8080 machine language routine adds two unsigned
8-bit numbers passed as the low-order bytes in the
BC and DE registers, and leaves the result in HL.
end
ml_code(1) = 79H rem MOV A,C
ml_code(2) = 83H rem ADD E
ml_code(3) = 6FH rem MOV L,A
ml_code(4) = 0C9H rem RET
bc = 7 rem first number
de = 12 rem second number
rem - call the routine and display the result (returned in HL)
call (ML_LOC, hl, de, bc, a_psw)
print bc; " plus"; de; " equals"; hl
end

View file

@ -0,0 +1,24 @@
#!/usr/bin/env gosh
#| -*- mode: scheme; coding: utf-8; -*- |#
(use c-wrapper)
(use gauche.uvector)
(use gauche.sequence)
(c-load '("sys/mman.h" "string.h"))
;; target architecture is x86_64 aka amd64
;; add 2 ints and return int
;; lea (%rsi,%rdi,1),%eax #x8d #x4 #x3e
;; retq #xc3
(define code #u8(#x8d #x4 #x3e #xc3))
(define buf (mmap 0
(size-of code)
(logior PROT_READ PROT_WRITE PROT_EXEC)
(logior MAP_PRIVATE MAP_ANONYMOUS)
-1
0))
(define (main args)
(memcpy buf code (size-of code))
(print ((cast (c-func-ptr <c-uchar> (list <c-uchar> <c-uchar>)) buf) 7 12))
(munmap buf (size-of code))
0)